package com.project.webpage.controller;


import com.project.webpage.entity.UserXl;
import com.project.webpage.service.UserService;
import com.project.webpage.util.RestResult;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

@RestController
@RequestMapping("/api/webpage/user/")
public class UserController extends BaseController {

    @Resource
    UserService userService;

    @PostMapping("xl/list")
    public RestResult xlList(@RequestHeader(value = "user") String user) {
        return RestResult.ok(userService.getXlList(user));
    }

    @PostMapping("xl/update")
    public RestResult xlUpdate(@RequestBody List<UserXl> list) {
        try {
            userService.updateXlList(list);
            return RestResult.ok();
        } catch (Exception e) {
            return RestResult.error(e.getMessage());
        }
    }
}
